Skip to content

Conversation

@wvangeit
Copy link
Contributor

@wvangeit wvangeit commented Apr 16, 2025

What do these changes do?

This introduces the Functions API.
Functions are objects that can be in the backend: projects, solvers, python code, etc ...
Users can create their own functions from the relevant objects.
They accept parameters and return results.
Each function run creates a function job. These function job can also act as a cache to prevent rerunning a function with the same parameters.

Related issue/s

#7506

How to test

There are tests in the api-server (Rest) and web/server (RPC) service directories.

A high-level functional test script is here:
https://github.com/wvangeit/osparc-functions-api-test/blob/master/test.py

Dev-ops checklist

@wvangeit wvangeit added a:api framework api, data schemas, Feedback labels Apr 16, 2025
@wvangeit wvangeit added this to the Pauwel Kwak milestone Apr 16, 2025
@wvangeit wvangeit requested a review from bisgaard-itis April 16, 2025 10:19
@wvangeit wvangeit self-assigned this Apr 16, 2025
@codecov
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 75.37500% with 197 lines in your changes missing coverage. Please review.

Project coverage is 86.03%. Comparing base (c552e46) to head (605fd28).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7539      +/-   ##
==========================================
- Coverage   87.57%   86.03%   -1.54%     
==========================================
  Files        1794     1731      -63     
  Lines       69368    68182    -1186     
  Branches     1136     1037      -99     
==========================================
- Hits        60747    58661    -2086     
- Misses       8311     9247     +936     
+ Partials      310      274      -36     
Flag Coverage Ξ” *Carryforward flag
integrationtests 59.88% <ΓΈ> (-4.85%) ⬇️ Carriedforward from e032e1e
unittests 86.64% <75.37%> (-0.25%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Ξ”
api βˆ… <ΓΈ> (βˆ…)
pkg_aws_library βˆ… <ΓΈ> (βˆ…)
pkg_dask_task_models_library βˆ… <ΓΈ> (βˆ…)
pkg_models_library 93.06% <100.00%> (+0.17%) ⬆️
pkg_notifications_library 85.26% <ΓΈ> (ΓΈ)
pkg_postgres_database 88.56% <100.00%> (+0.14%) ⬆️
pkg_service_integration 69.92% <ΓΈ> (ΓΈ)
pkg_service_library 72.02% <0.00%> (-0.87%) ⬇️
pkg_settings_library βˆ… <ΓΈ> (βˆ…)
pkg_simcore_sdk 65.71% <ΓΈ> (-19.96%) ⬇️
agent 96.46% <ΓΈ> (ΓΈ)
api_server 91.52% <78.69%> (-0.99%) ⬇️
autoscaling 96.08% <ΓΈ> (ΓΈ)
catalog 92.64% <ΓΈ> (ΓΈ)
clusters_keeper 99.25% <ΓΈ> (ΓΈ)
dask_sidecar 89.88% <ΓΈ> (ΓΈ)
datcore_adapter 98.12% <ΓΈ> (ΓΈ)
director 76.80% <ΓΈ> (ΓΈ)
director_v2 84.64% <ΓΈ> (-6.56%) ⬇️
dynamic_scheduler 96.76% <ΓΈ> (ΓΈ)
dynamic_sidecar 90.15% <ΓΈ> (ΓΈ)
efs_guardian 89.79% <ΓΈ> (ΓΈ)
invitations 93.28% <ΓΈ> (ΓΈ)
payments 92.63% <ΓΈ> (ΓΈ)
resource_usage_tracker 89.13% <ΓΈ> (+0.10%) ⬆️
storage 87.74% <ΓΈ> (ΓΈ)
webclient βˆ… <ΓΈ> (βˆ…)
webserver 85.01% <80.23%> (-0.86%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update c552e46...605fd28. Read the comment docs.

πŸš€ New features to boost your workflow:
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@bisgaard-itis bisgaard-itis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the great effort Werner! It looks very cool.
I suggest several minor changes, but I have one big request and that concerns running the function. I think it is crucial that that happens asyncronously and in one of our dedicated celery workers. This call (in the case of studies) was exactly what was blocking us last time we did the metamodeling. We are in a better position now because we have a job scheduling framework for handling "internal long running tasks". We should use it! 😁

@wvangeit
Copy link
Contributor Author

Thanks a lot for the great effort Werner! It looks very cool. I suggest several minor changes, but I have one big request and that concerns running the function. I think it is crucial that that happens asyncronously and in one of our dedicated celery workers. This call (in the case of studies) was exactly what was blocking us last time we did the metamodeling. We are in a better position now because we have a job scheduling framework for handling "internal long running tasks". We should use it! 😁

Yeah, sure makes sense. I'm basically calling the study_job api. It's probably best to implement the celery changes there? (it they're not there yet)

Copy link
Contributor

@bisgaard-itis bisgaard-itis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the changes. I had another look and provided some more feedback. I think it is quite critical that we sort out the run function so that creating it becomes a long running task in a celery worker somewhere.

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few more comments and suggestions.
Also a way to simplify the api-server's tests which will remove quite some code and make them more intuitive when reading.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Enables the new Functions API end-to-end by removing legacy stubs, adding RPC client wrappers, Pydantic schemas, HTTP routes, database tables, and migrations.

  • Removes old webserver RPC controller for functions.
  • Adds RPC client methods in WbApiRpcClient and Pydantic schemas for functions, jobs, and collections.
  • Registers new /functions, /function_jobs, and /function_job_collections routes and creates SQL tables with migrations.

Reviewed Changes

Copilot reviewed 28 out of 30 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/web/server/src/simcore_service_webserver/functions/_controller_rpc.py Removed old RPC router and ping endpoint
services/api-server/tests/unit/api_functions/conftest.py Added fixtures and dummy RPC client for functions API tests
services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py Added wrapper methods for functions RPC in WbApiRpcClient
services/api-server/src/simcore_service_api_server/models/schemas/functions_api_schema.py New Pydantic schemas for functions, jobs, and collections
services/api-server/src/simcore_service_api_server/api/root.py Registered new routers for functions, jobs, and collections
packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/webserver/functions/ RPC interface implementations for all functions endpoints
packages/postgres-database/src/simcore_postgres_database/models/funcapi_*.py Added tables for functions, jobs, collections, and join
packages/postgres-database/src/simcore_postgres_database/migration/versions/*.py Alembic scripts to create and evolve function API tables
Files not reviewed (2)
  • services/api-server/requirements/_test.in: Language not supported
  • services/api-server/requirements/_test.txt: Language not supported
Comments suppressed due to low confidence (2)

services/api-server/src/simcore_service_api_server/models/schemas/functions_api_schema.py:74

  • [nitpick] The FunctionJobCollection model uses id for its primary key field while other models use uid; consider renaming id to uid for consistency across your schemas.
class FunctionJobCollection(BaseModel):

services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py:3

  • The imports dataclass and partial are unused in this file; please remove them to clean up dependencies.
from dataclasses import dataclass

Copy link
Collaborator

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry didn't have time to go over it, but I do not want to block you so approve, I will go over it as soon as possible.

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I added a few comments.
For next time please create smaller PRs that are easier to review (you will also get faster reviews):

  • 1 PR with database changes
  • 1 PR with API changes,
  • ...

Thank you and good luck!

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already approved.

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the changes!
I'm OK with it, just some minor things still remain.

@sonarqubecloud
Copy link

@wvangeit
Copy link
Contributor Author

@mergify queue

@mergify
Copy link
Contributor

mergify bot commented May 15, 2025

queue

βœ… The pull request has been merged automatically

The pull request has been merged automatically at 67c3d67

@wvangeit wvangeit added the πŸ€–-automerge marks PR as ready to be merged for Mergify label May 15, 2025
@mergify mergify bot merged commit 67c3d67 into ITISFoundation:master May 15, 2025
92 of 96 checks passed
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Jun 6, 2025
92 tasks
@wvangeit wvangeit deleted the functions_draft branch August 5, 2025 09:39
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Aug 5, 2025
88 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

πŸ€–-automerge marks PR as ready to be merged for Mergify a:api framework api, data schemas, a:apiserver api-server service a:database associated to postgres service and postgres-database package a:webserver webserver's codebase. Assigning the area is particularly useful for bugs Meta-modeling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants